cmake_minimum_required(VERSION 2.8)
project(3DMapSL)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-O3")
set(CMAKE_CXX_FLAGS "-fopenmp")
IF (CMAKE_BUILD_TYPE MATCHES "Debug")
        MESSAGE(STATUS "CMAKE_BUILD_TYPE = Debug")
ELSEIF (CMAKE_BUILD_TYPE MATCHES "Release")
        MESSAGE(STATUS "CMAKE_BUILD_TYPE = Release")
ELSE()
        set(CMAKE_BUILD_TYPE "Release")
        MESSAGE(STATUS "Set defalult CMAKE_BUILD_TYPE = Release")
ENDIF()

add_subdirectory(SfM)
add_subdirectory(Algo)
add_subdirectory(Db)

include_directories(/usr/include/eigen3
        ./)

#find_package(PCL 1.9 REQUIRED)
#include_directories(${PCL_INCLUDE_DIRS})
#link_directories(${PCL_LIBRARY_DIRS})
#add_definitions(${PCL_DEFINITIONS})
#${PCL_LIBRARIES}

SET(LIBRARIES       
        /usr/local/lib/colmap/libflann.a
        /usr/local/lib/colmap/libcolmap.a
        /usr/local/lib/colmap/libvlfeat.a
        boost_iostreams
        boost_program_options
        boost_filesystem
        boost_system
        boost_serialization
        boost_regex
        opencv_xfeatures2d
        opencv_calib3d
        opencv_features2d
        opencv_flann
        opencv_highgui
        opencv_imgcodecs
        opencv_imgproc
        opencv_core
        png
        z
        jpeg
        tiff
        glog
        ceres
        pthread
        cholmod
        ccolamd
        camd
        colamd
        amd
        lapack
        blas
        cxsparse
        gomp
        freeimage
        dl
        tbb
        proj)
        
find_package(CUDA)
if(CUDA_FOUND)
        set(LIBRARIES "${LIBRARIES}" 
                /usr/local/lib/colmap/libsift_gpu.a
                /usr/local/cuda-10.0/lib64/libcudart.so
                OpenGL
                glut
                GLEW)
else()
	MESSAGE("-- Can't find CUDA. Continuing without it.")
endif()

add_executable(3DMapSL main.cpp)
target_link_libraries(3DMapSL algo sfm db ${LIBRARIES})